import { Component, OnInit } from "@angular/core";

import { UserService } from "./user.service";
import { User } from "./user.model";
import { LOGOS } from "shared";

interface UserType {
  bindQy: boolean;
  bindWx: boolean;
  customerCode: string;
  iconUrl: string;
  loginName: string;
  loginOps: string;
  mobile: string;
  name: string;
  passwd: boolean;
  totalContract: number;
  totalOrder: number;
  userId: number;
  verified: boolean;
}

@Component({
  selector: "user-account",
  templateUrl: "user.component.html",
  styleUrls: ["user.component.less"]
})
export class UserComponent implements OnInit {
  constructor(private us: UserService) {
    us.personSub.subscribe((person: UserType) =>{
      if ( person.iconUrl ) {
        this.loginImg = person.iconUrl;
      }
    })
  }
  loginImg = LOGOS.loginUser;

  ngOnInit() {
    this.us.queryUser();
  }

  logout() {
    if(window.confirm('你确定要退出登录吗？')){
        //alert("确定");
      this.loginImg = LOGOS.loginUser;
      this.us.setModal('logout');
    }else{
      //alert("取消");
      return false;
    }
  }
}